/**    
 * 文件名：Ex5EqualizeHistogram.java    
 *    
 * 版本信息：    
 * 日期：2014年3月10日    
 * xyj 足下 xyj 2014     
 * 版权所有    
 *    
 */
package opencvtest.chapter04;

import static com.googlecode.javacv.cpp.opencv_highgui.CV_LOAD_IMAGE_GRAYSCALE;
import static opencvtest.OpenCVUtils.loadAndShowOrExit;
import static opencvtest.OpenCVUtils.show;

import java.io.File;

import com.googlecode.javacv.cpp.opencv_core.IplImage;

/**
 * Modifies image using histogram equalization. Example for section
 * "Equalizing the image histogram" in Chapter 4.
 */
public class Ex5EqualizeHistogram {

    public static void main(String[] args) {

        // Load image as a gray scale
        IplImage src = loadAndShowOrExit(new File("data/group.jpg"), CV_LOAD_IMAGE_GRAYSCALE);
        // Show histogram of the source image
        show(new Histogram1D().getHistogramImage(src), "Input histogram");

        // Apply look-up
        IplImage dest = Histogram1D.equalize(src);

        // Show inverted image
        show(dest, "Equalized Histogram");
        // Show histogram of the modified image
        show(new Histogram1D().getHistogramImage(dest), "Equalized histogram");

    }

}
